#version 460
#extension GL_GOOGLE_include_directive : enable
#extension GL_EXT_nonuniform_qualifier : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
#extension GL_EXT_shader_explicit_arithmetic_types_int16 : require
#extension GL_EXT_shader_explicit_arithmetic_types_int8 : require


#include "../../../../core/shader_binding_ID.h"
#include "../../../../core/shader_std.h"
#include "../../../../core/shader_built_in_functions.h"


layout(points) in;
layout(line_strip, max_vertices=2) out;

layout(location = 0) in vec3 inEyeDir[];
layout(location = 1) in vec3 inNormal[];
layout(location = 2) in vec4 inVert[];
layout(location = 3) in float inUV[];
layout(location = 4) in uint inMaterialID[];
//layout(location = 5) in uint inOffset_Face[];

in gl_PerVertex {
	vec4 gl_Position;
}gl_in[];



layout(location = 0) out vec3 outEyeDir;
layout(location = 1) out vec3 outNormal;
layout(location = 2) out vec4 outVert;
layout(location = 7) out flat uint outMaterialID;
//layout(location = 8) out float outElementID;
layout(location = 9) out float outUV;

out gl_PerVertex {
	vec4 gl_Position;
};



void main(void){

	//vec3 normal = normalize(f_surface_FaceNormal(gl_in[0].gl_Position.xyz, gl_in[1].gl_Position.xyz, gl_in[2].gl_Position.xyz));
	//vec3 normal = normalize(f_surface_FaceNormal(inNormal[0], inNormal[1], inNormal[2]));
	//vec3 normal = normalize(gl_in[0].gl_Position.xyz + gl_in[1].gl_Position.xyz + gl_in[2].gl_Position.xyz);

	for(uint i=0; i<2; ++i){
		outEyeDir = inEyeDir[i];
		outNormal = inNormal[i];
		outVert = inVert[i];
		outMaterialID = inMaterialID[i];

		//outElementID = 1;
		outUV = inUV[i];
		
		gl_Position = gl_in[i].gl_Position;
		//gl_Position.z += outUV*0.01;
		EmitVertex();
	}
	
	EndPrimitive();
}



